<template>
	<view>
		<view class="tabs">
			<view class="tabs-one" @click="changetab(1)">
				<view class="tabs-top" :class="num==1?'color':''">
					承诺卡
				</view>
				<view class="tabs-color" :class="num==1?'avtive':''">

				</view>
			</view>
			<view class="tabs-one" @click="changetab(2)">
				<view class="tabs-top" :class="num==2?'color':''">
					应知卡
				</view>
				<view class="tabs-color" :class="num==2?'avtive':''">

				</view>
			</view>
			<view class="tabs-one" @click="changetab(3)">
				<view class="tabs-top" :class="num==3?'color':''">
					处置卡
				</view>
				<view class="tabs-color" :class="num==3?'avtive':''">

				</view>
			</view>

		</view>

		<view class="cont">
			<!-- 承诺卡 -->
			<view class="" v-if="num==1">
				<view class="content">
					<view class="shortanswer">
						<view class="shortanswer-title">
							<text class="one">承诺卡编号</text>
							<text class="two">{{obj.cnkbh}}</text>
						</view>
						<view class="shortanswer-title">
							<text class="one">承诺人</text>
							<text class="two">{{obj.cnrmc}}</text>
						</view>
						<view class="shortanswer-title">
							<text class="one">主管领导</text>
							<text class="two">{{obj.zgldmc}}</text>
						</view>
						<view class="shortanswer-title">
							<text class="one">岗位名称</text>
							<text class="two">{{obj.gwmc}}</text>
						</view>
						<view class="shortanswer-title">
							<text class="one">承诺日期</text>
							<text class="two">{{obj.cnrq}}</text>
						</view>

						<view class="shortanswer-content">
							<view class="text">
								<text>承诺事项</text>
							</view>
							<textarea style="background-color: #F6F6F6;color: #C5C5C5;font-size: 24rpx;"
								v-model="obj.cnsx" placeholder="承诺事项长文本..."></textarea>
						</view>
						<view class="shortanswer-content">
							<view class="text">
								<text>承诺卡照片</text>
							</view>
							<view class="img">
							<img style='width: ;' :src="obj.fj" alt="">
							</view>
						</view>
					</view>
				</view>

			</view>
		</view>

		<!-- 应知卡 -->
		<view class="" v-if="num==2">
			<view class="content">
				<view class="shortanswer">
					<view class="shortanswer-title">
						<text class="one">应知卡编号</text>
						<text class="two">{{obj1.yzkbh}}</text>
					</view>
					<view class="shortanswer-title">
						<text class="one">岗位名称</text>
						<text class="two">{{obj1.gwmc}}</text>
					</view>

					<view class="shortanswer-content">
						<view class="text">
							<text>主要危险有害因素</text>
						</view>
						<textarea style="background-color: #F6F6F6;color: #C5C5C5;font-size: 24rpx;" v-model="obj1.zywxyhys"
							placeholder="主要危险有害因素长文本..."></textarea>
					</view>
					<view class="shortanswer-content bb">
						<view class="text">
							<text>易导致事故风险</text>
						</view>
						<textarea style="background-color: #F6F6F6;color: #C5C5C5;font-size: 24rpx;" v-model="obj1.ydzsgfx"
							placeholder="易导致事故风险..."></textarea>
					</view>
					<view class="shortanswer-title">
						<text class="one">风险等级</text>
						<text class="two">{{obj1.fxdj}}</text>
					</view>
					<view class="shortanswer-content">
						<view class="text">
							<text>风险管控措施</text>
						</view>
						<textarea style="background-color: #F6F6F6;color: #C5C5C5;font-size: 24rpx;" v-model="obj1.fxgkcs"
							placeholder="主要危险有害因素长文本..."></textarea>
					</view>
					<view class="shortanswer-content bb">
						<view class="text">
							<text>应急处置对策</text>
						</view>
						<textarea style="background-color: #F6F6F6;color: #C5C5C5;font-size: 24rpx;" v-model="obj1.yjcsdc"
							placeholder="应急处置对策..."></textarea>
					</view>
					<view class="shortanswer-title">
						<text class="one">警示标识</text>
						<text class="two">{{obj1.aqjsbs}}</text>
					</view>
					<view class="shortanswer-content">
						<view class="text">
							<text>应知卡照片</text>
						</view>
						<view class="img">
<img :src="obj1.fj" alt="">
						</view>
					</view>
				</view>
			</view>

		</view>
		<!-- 处置卡 -->
		<view class="" v-if="num==3">
			<view class="content">
				<view class="shortanswer">
					<view class="shortanswer-title">
						<text class="one">处置卡名称</text>
						<text class="two">{{obj2.yjkmc}}</text>
					</view>
					<view class="shortanswer-title">
						<text class="one">处置卡编号</text>
						<text class="two">{{obj2.czkbh}}</text>
					</view>
					<view class="shortanswer-title">
						<text class="one">关联岗位</text>
						<text class="two">{{obj2.glgwmc}}</text>
					</view>
					<view class="shortanswer-title">
						<text class="one">主要负责人</text>
						<text class="two">{{obj2.zyzrrmc}}</text>
					</view>
					<view class="shortanswer-title">
						<text class="one">内部应急电话</text>
						<text class="two">{{obj2.nbyjdh}}</text>
					</view>
					<view class="shortanswer-title">
						<text class="one">外部应急电话</text>
						<text class="two">{{obj2.wbyjdh}}</text>
					</view>

					
					<view class="shortanswer-content bb">
						<view class="text">
							<text>事故风险</text>
						</view>
						<textarea style="background-color: #F6F6F6;color: #C5C5C5;font-size: 24rpx;" v-model="obj2.sgfx"
							placeholder="易导致事故风险..."></textarea>
					</view>
					<view class="shortanswer-content">
						<view class="text">
							<text>发生场所</text>
						</view>
						<textarea style="background-color: #F6F6F6;color: #C5C5C5;font-size: 24rpx;" v-model="obj2.fscs"
							placeholder="发生场所长文本..."></textarea>
					</view>
					<view class="shortanswer-content bb">
						<view class="text">
							<text>工艺说明</text>
						</view>
						<textarea style="background-color: #F6F6F6;color: #C5C5C5;font-size: 24rpx;" v-model="obj2.gysm"
							placeholder="工艺说明..."></textarea>
					</view>
					<view class="shortanswer-content bb">
						<view class="text">
							<text>事故特征</text>
						</view>
						<textarea style="background-color: #F6F6F6;color: #C5C5C5;font-size: 24rpx;" v-model="obj2.sgtz"
							placeholder="事故特征..."></textarea>
					</view>
					<view class="shortanswer-content">
						<view class="text">
							<text>危害描述</text>
						</view>
						<textarea style="background-color: #F6F6F6;color: #C5C5C5;font-size: 24rpx;" v-model="obj2.whms"
							placeholder="危害描述长文本..."></textarea>
					</view>
					<view class="shortanswer-content">
						<view class="text">
							<text>步骤说明</text>
						</view>
						<textarea style="background-color: #F6F6F6;color: #C5C5C5;font-size: 24rpx;" v-model="obj2.bzsm"
							placeholder="步骤说明长文本..."></textarea>
					</view>
					<view class="shortanswer-content bb">
						<view class="text">
							<text>处置措施</text>
						</view>
						<textarea style="background-color: #F6F6F6;color: #C5C5C5;font-size: 24rpx;" v-model="obj2.czcs"
							placeholder="处置措施..."></textarea>
					</view>
					<view class="shortanswer-content bb">
						<view class="text">
							<text>注意事项</text>
						</view>
						<textarea style="background-color: #F6F6F6;color: #C5C5C5;font-size: 24rpx;" v-model="obj2.zysx"
							placeholder="注意事项..."></textarea>
					</view>

					<view class="shortanswer-content">
						<view class="text">
							<text>处置卡照片</text>
						</view>
						<view class="img">
							<img :src="obj2.fj" alt="">
						</view>
					</view>
				</view>


			</view>

		</view>
	</view>
	</view>
</template>

<script>
	import {
		userdetail,
		cnlist,
		ycdetail,
		czdetail
	} from '@/api/userid.js'
	export default {
		data() {
			return {
				num: 1,
				id: '',
				obj: {},
				obj1: {},
				obj2: {},
				
			};
		},
		onShow() {
			this.userId = uni.getStorageSync('userId')
			this.id = this.userId
			this.init()
		},
		methods: {
			changetab(index) {
				this.num = index
				userdetail(this.id).then(res => {
					console.log(res.data.postId)
					if(index==2){
						ycdetail({id:res.data.postId}).then(res => {
							if(res.data==null){
								uni.showToast({
									icon:'none',
									title:'暂无数据'
								})
								return
							}
							this.obj1 = res.data
						})
					}else if(index==3){
						czdetail({id:res.data.postId}).then(res => {
							if(res.data==null){
								uni.showToast({
									icon:'none',
									title:'暂无数据'
								})
								return
							}
							this.obj2 = res.data
						})
					}
				})
				
			},
			init() {
				cnlist({cnr:5}).then(res => {
					this.obj = res.data[0]
				})
			},
		}
	}
</script>

<style lang="scss">
	.avtive {
		background: #1989FA !important;
	}

	.color {
		color: #1989FA !important;
	}

	.tabs {
		display: flex;
		justify-content: space-around;

		.tabs-one {
			width: 311rpx;
			height: 82rpx;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;

			.tabs-top {
				width: 112rpx;
				height: 44rpx;
				font-size: 28rpx;
				font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 500;
				color: #999;
				line-height: 44rpx;

			}

			.tabs-color {
				width: 64rpx;
				height: 6rpx;
				margin-top: 15rpx;
				background: #fff;
			}
		}
	}

	.cont {
		// padding: 40rpx 24rpx;
		// background-color: #f6f6f6;


	}

	.content {
		width: 100%;
		padding: 40rpx 24rpx 60rpx;
		box-sizing: border-box;

		.shortanswer {
			width: 100%;
			padding: 0 48rpx 24rpx;
			box-sizing: border-box;
			background-color: #fff;
			border-radius: 16rpx;
			margin-bottom: 40rpx;

			.shortanswer-title {
				width: 100%;
				height: 108rpx;
				line-height: 108rpx;
				margin-bottom: 30rpx;
				box-sizing: border-box;
				border-bottom: 1rpx solid #EEEEEE;
				color: #666666;
				font-size: 28rpx;

				.one {
					width: 180rpx;
					color: #999999;
					font-size: 28rpx;
					margin-right: 64rpx;
					display: inline-block;
				}
			}

			.shortanswer-content {
				width: 100%;

				.text {
					margin-bottom: 16rpx;

					text {
						color: #999999;
						font-size: 28rpx;
					}
				}

				.uni-textarea-wrapper {
					background-color: #F6F6F6 !important;
				}

				.img {
					width: 220rpx;
					height: 220rpx;
					img{
						width: 100%;
						height: 220rpx;
						border-radius: 10rpx;
					}
				}

			}

			.bb {
				border-bottom: 1rpx solid #EEEEEE;
			}
		}
	}
</style>
